from flask import Blueprint, render_template
from application import api, db
from flask_restx import Resource
from utils import response
from user.models import User

user_router = Blueprint('user', __name__, url_prefix="/api/user")

ns = api.namespace("user", description="user module")


@ns.route('/add')
class Health(Resource):
  @api.doc('添加用户')
  def get(self):
    user = User(username='xhh', password='333')
    db.session.add(user)
    db.session.commit()
    return response(code=200, message='OK')


@ns.route('/get')
class Health(Resource):
  @api.doc('获取用户')
  def get(self):
    user = User.query.get(1)
    return response(code=200, message='OK', data=user)
